﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:ctrls="clr-namespace:Odyssey.Controls;assembly=Odyssey"
    xmlns:data="clr-namespace:System.Windows.Data;assembly=System.Windows"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:bh="clr-namespace:Odyssey.Behaviors;assembly=Odyssey"
    xmlns:utils="clr-namespace:OdcTest.Utils"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vm="clr-namespace:OdcTest.ViewModels"
    xmlns:cm="clr-namespace:System.ComponentModel;assembly=System"
    xmlns:fx="clr-namespace:Odyssey.Effects;assembly=Odyssey"
    xmlns:Custom="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
    xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" 
    x:Class="OdcTest.Views.FeatherFxDemo"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480" bh:TiltEffect.IsTiltEnabled="True"
    shell:SystemTray.IsVisible="True">

    <phone:PhoneApplicationPage.Resources>
        <ctrls:ThrottledSourceConverter From="8" To="9" Interval="0:0:0.1" x:Key="srcConverter"/>
        <!--<utils:SourceConverter x:Key="srcConverter"/>-->
    </phone:PhoneApplicationPage.Resources>

    <phone:PhoneApplicationPage.FontFamily>
        <StaticResource ResourceKey="PhoneFontFamilyNormal"/>
    </phone:PhoneApplicationPage.FontFamily>
    <phone:PhoneApplicationPage.FontSize>
        <StaticResource ResourceKey="PhoneFontSizeNormal"/>
    </phone:PhoneApplicationPage.FontSize>
    <phone:PhoneApplicationPage.Foreground>
        <StaticResource ResourceKey="PhoneForegroundBrush"/>
    </phone:PhoneApplicationPage.Foreground>

    <phone:PhoneApplicationPage.DataContext>
        <vm:DataViewModel   />
    </phone:PhoneApplicationPage.DataContext>

    <Custom:Interaction.Behaviors>
        <bh:FeatherEffectBehavior Duration="0:0:0.10" WaitUntilCompleted="True" BackDelay="0:0:0.1"  Amplitude="3" />
    </Custom:Interaction.Behaviors>

    <Custom:Interaction.Triggers>
        <Custom:EventTrigger EventName="ItemInvoked" SourceName="listBox">
            <bh:FeatherEffectAction Duration="0:0:0.25" Amplitude="2"/>
            <ic:NavigateToPageAction TargetPage="/Views/DetailPage.xaml?effect=swingFx"/>
        </Custom:EventTrigger>
    </Custom:Interaction.Triggers>

    <Grid x:Name="LayoutRoot" Background="Transparent"  >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="ODYSSEY" Style="{StaticResource PhoneTextNormalStyle}" fx:FeatherEffect.IsElement="True"  CacheMode="BitmapCache"/>
            <TextBlock x:Name="PageTitle" Text="feather effect" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" fx:FeatherEffect.IsElement="True"  CacheMode="BitmapCache"/>
        </StackPanel>

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" fx:ContinuumEffect.Slide="True" CacheMode="BitmapCache">
            <ctrls:OdcListBox x:Name="listBox" ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" IsIntervalEnabled="false">
                <!--, Converter={StaticResource srcConverter}-->

                <ctrls:OdcListBox.ItemContainerStyle>
                    <Style TargetType="ctrls:OdcListBoxItem">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ctrls:OdcListBoxItem">
                                    <Border>
                                        <Grid x:Name="grid" Opacity="1" CacheMode="BitmapCache"    Margin="64,0,0,0"
                                          fx:FeatherEffect.IsElement="True" 
                                          fx:FeatherEffect.IsLast="{Binding IsSelected, RelativeSource={RelativeSource TemplatedParent}}">
                                            <Rectangle Fill="{StaticResource PhoneChromeBrush}" Width="72" Height="72" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,5"/>
                                            <TextBlock Text="{Binding Name}" 
                                                   FontSize="{StaticResource PhoneFontSizeExtraLarge}" Margin="90,0,0,0" VerticalAlignment="Center"/>
                                            <!--<TextBox Text="{Binding Name}"  Margin="90,0,0,0" VerticalAlignment="Center"  />-->
                                        </Grid>
                                    </Border>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ctrls:OdcListBox.ItemContainerStyle>
            </ctrls:OdcListBox>

        </Grid>
    </Grid>

</phone:PhoneApplicationPage>
